package com.wngbms;

import java.util.concurrent.*;

public class _03_04 {

    public static void main(String[] args) throws InterruptedException, ExecutionException {
        long start = System.currentTimeMillis();

        CompletableFuture<Integer> f1 = CompletableFuture.supplyAsync(_03_04::sum);

        System.out.println("异步计算结果为：" + f1.get());
        System.out.println("使用时间：" + (System.currentTimeMillis() - start) + " ms");
    }

    private static int sum() {
        return fibo(36);
    }

    private static int fibo(int a) {
        if (a < 2)
            return 1;
        return fibo(a - 1) + fibo(a - 2);
    }
}
